package com.xctech.yace.single;

import com.xctech.yace.pojo.Message;
import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.HashMap;
import java.util.Map;

@Data
@AllArgsConstructor
public class DataMap {


    private static DataMap instance;

    static {
        instance = new DataMap();
    }

    private DataMap() {
    }

    public static DataMap getInstance(){
        return instance;
    }


    public synchronized Map<String, Message> getDatas(){
        return datas;
    }

    public synchronized void addData(String key,Message message){
        datas.put(key,message);
    }

    public synchronized Message getSingleData(String key){
        return datas.get(key);
    }    private Map<String, Message> datas = new HashMap<>();


}
